package com.service.impl;

import com.service.MqInitService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import static core.Constants.Mq.*;

@Service
public class MqInitServiceImpl implements MqInitService {
    private RabbitTemplate rabbitTemplate;

    public MqInitServiceImpl(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @Override
    public void init() {
        rabbitTemplate.convertAndSend(EXCHANGE_NAME,ROUTING_KEY_INIT,"init mq");
        Object result = rabbitTemplate.receiveAndConvert(QUEUE_INIT);
        System.out.println("result msg from mq = " + result);
    }
}
